package com.loong.web.suppert.collection.param;

/**
 * 分页参数
 *
 * @author 张成轩
 */
public class PageParam {

	private static final int DEFAULT_PAGE = 1;
	private static final int DEFAULT_PAGE_SIZE = 10;

	private Integer page;
	private Integer size;
	private String order;
	private Integer total;

	/**
	 * @return 页
	 */
	public Integer getPage() {

		if (page == null)
			page = DEFAULT_PAGE;
		return page;
	}

	/**
	 * @param page 页
	 */
	public void setPage(Integer page) {

		this.page = page;
	}

	/**
	 * @return 页容量
	 */
	public Integer getSize() {

		if (size == null)
			size = DEFAULT_PAGE_SIZE;
		return size;
	}

	/**
	 * @param size 页容量
	 */
	public void setSize(Integer size) {

		this.size = size;
	}

	/**
	 * @return 起始索引
	 */
	public Integer getStart() {

		return (getPage() - 1) * getSize();
	}

	/**
	 * @return 终止索引
	 */
	public Integer getEnd() {

		return getPage() * getSize() - 1;
	}

	/**
	 * @return 排序
	 */
	public String getOrder() {

		return order;
	}

	/**
	 * @param order 排序
	 */
	public void setOrder(String order) {

		this.order = order;
	}

	/**
	 * @return 总数
	 */
	public Integer getTotal() {

		if (total == null)
			return 0;
		return total;
	}

	/**
	 * @param total 总数
	 */
	public void setTotal(Integer total) {

		this.total = total;
	}
}
